package com.wf.provider;

import com.wf.entity.PageInfo;
import com.wf.entity.Power;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * Created by yuzhongbo on 2017/5/3.
 */
@Component
@FeignClient("wf-power")
public interface PowerProvider {

    //Operation(value="获取权限列表", notes="根据Power获取权限列表")
    //ImplicitParam(name = "power", value = "Power", required = false, dataType = "Power")
    @LoadBalanced
    @RequestMapping(value = "/power")
    public PageInfo<Power> getAllByPage(@ModelAttribute(value = "power") Power power);

    //Operation(value="获取权限", notes="根据权限id获取权限")
    //ImplicitParam(name = "id", value = "权限id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/power/get/{id}")
    public Power get(@PathVariable(value = "id") String id);

    //Operation(value="获取权限", notes="根据权限获取权限")
    //ImplicitParam(name = "power", value = "Power", required = false, dataType = "Power")
    @LoadBalanced
    @RequestMapping(value = "/power/selectOne")
    public Power selectOne(@ModelAttribute(value = "power") Power power);

    //Operation(value="删除权限", notes="根据权限id删除权限")
    //ImplicitParam(name = "id", value = "权限id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/power/delete/{id}")
    public ModelMap delete(@PathVariable(value = "id") String id);

    //Operation(value="保存（添加/修改）权限", notes="根据Power创建权限")
    //ImplicitParam(name = "power", value = "权限实体Power", required = true, dataType = "Power")
    @LoadBalanced
    @RequestMapping(value = "/power/save", method = RequestMethod.POST)
    public ModelMap save(@ModelAttribute(value = "power") Power power);

    //Operation(value="获取用户按钮权限", notes="根据用户id获取按钮权限")
    //ImplicitParam(name = "userId", value = "用户id", required = true, dataType = "String")
    @LoadBalanced
    @RequestMapping(value = "/power/getPowersByUserId/{userId}")
    public List<Power> getPowersByUserId(@PathVariable(value = "userId") String userId);
}
